package cn.chendd.bootsrtap.controller;

import cn.chendd.bootsrtap.service.TransactionalService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 事务管理 Controller
 *
 * @author chendd
 * @date 2023/1/20 16:38
 */
@RestController
@RequestMapping("/api")
public class TransactionalController {

    @Resource
    private TransactionalService transactionalService;

    @GetMapping("/commit")
    public void saveDataCommit() {
        this.transactionalService.saveDataCommit();
    }

    @GetMapping("/rollback1")
    public void saveDataRollback1() {
        this.transactionalService.saveDataRollback1();
    }

    @GetMapping("/rollback2")
    public void saveDataRollback2() {
        this.transactionalService.saveDataRollback2();
    }

}
